<template>
  <div v-loading="loading" class="list-table">
    <div class="area-header">
      <span class="area-header-title">{{ $t('出资基金') }}</span>
    </div>
    <el-form ref="queryForm" :model="queryParams" :inline="true" @submit.native.prevent>
      <el-form-item :label="$t('基金名称')" prop="fundName">
        <el-input
          v-model="queryParams.fundName"
          :placeholder="$t('基金名称')"
          clearable
          @keyup.enter.native="queryHandle"
        />
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="queryHandle">{{ $t("搜索") }}</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">{{ $t("重置") }}</el-button>
      </el-form-item>
    </el-form>
    <el-table v-loading="loading" tooltip-effect="darkTable" :data="fundInvestorList" border>
      <el-table-column :label="$t('序号')" type="index" align="center" show-overflow-tooltip width="50">
        <template slot-scope="scope">
          {{ (queryParams.pageNum - 1) * queryParams.pageSize + scope.$index + 1 }}
        </template>
      </el-table-column>
      <el-table-column :label="$t('基金名称')" prop="fundName" align="center" show-overflow-tooltip min-width="200">
        <template slot-scope="scope">
          <router-link
            target="_blank"
            :to="{path:'/fund/fundBasehome',query:{id:scope.row.fundId}}"
            class="link_a"
            @click.native="recorePath({ fromPath: $route.fullPath, path:'/fund/fundBasehome',query:{id:scope.row.fundId}})"
          >
            {{ $t(scope.row.fundName) }}
          </router-link>
        </template>
      </el-table-column>
      <el-table-column :label="$t('认缴时间')" align="center" prop="timeSubscription" show-overflow-tooltip min-width="120">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.timeSubscription) }}</span>
        </template>
      </el-table-column>
      <el-table-column :label="$t('认缴金额') + $t('金额单位')" align="center" prop="subscribedAmount" show-overflow-tooltip min-width="120">
        <template slot-scope="scope">
          <span>{{ moneyFormat(scope.row.subscribedAmount, 'w') }}</span>
        </template>
      </el-table-column>
      <el-table-column :label="$t('认缴比例(%)')" align="center" prop="subscriptionRatio" show-overflow-tooltip min-width="120">
        <template slot-scope="scope">
          <span>{{ moneyFormat(scope.row.subscriptionRatio * 100) }}</span>
        </template>
      </el-table-column>
      <el-table-column :label="$t('累计实缴金额') + $t('金额单位')" align="center" prop="accumulatedPaidMount" show-overflow-tooltip min-width="120">
        <template slot-scope="scope">
          <span>{{ moneyFormat(scope.row.accumulatedPaidMount, 'w') }}</span>
        </template>
      </el-table-column>
      <el-table-column :label="$t('缴款进度(%)')" align="center" prop="paidInProgress" show-overflow-tooltip min-width="120">
        <template slot-scope="scope">
          <span>{{ moneyFormat(scope.row.paidInProgress * 100) }}</span>
        </template>
      </el-table-column>
      <el-table-column :label="$t('合伙协议签订时间')" align="center" prop="investmentTime" show-overflow-tooltip min-width="120">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.investmentTime) }}</span>
        </template>
      </el-table-column>
      <el-table-column :label="$t('最新IRR')" align="center" prop="latestIrr" show-overflow-tooltip min-width="120" />
      <el-table-column :label="$t('操作')" fixed="right" align="center" class-name="small-padding fixed-width" width="200">
        <template slot-scope="scope">
          <el-button
            v-hasPermi="['fund:investor:view']"
            size="small"
            type="text"
            icon="el-icon-view"
            @click="viewHandle(scope.row)"
          >{{ $t('查看') }}</el-button>
        </template>
      </el-table-column>
    </el-table>

    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />
    <el-dialog :title="title" :visible.sync="investFormOpen" :close-on-click-modal="false" :lock-scroll="false" custom-class="dialogForm" append-to-body>
      <fundInvestorForm ref="fundInvestorForm" :other-btn-hide="otherBtnHide" />
    </el-dialog>
  </div>
</template>

<script>
  import {
    findFundInvestor
  } from '@/api/fund/internal/internalBase'
  import fundInvestorForm from '@/views/fund/investor/fundInvestorForm.vue'
  export default {
    name: 'InternalInvestFundList',
    components: {
      fundInvestorForm
    },
    data() {
      return {
        // 遮罩层
        loading: true,
        // 出资基金表格数据
        fundInvestorList: [],
        // 弹出层标题
        title: '',
        // 是否显示弹出层
        investFormOpen: false,
        otherBtnHide: true,
        // 查询参数
        queryParams: {
          customerId: this.$route.query.id,
          fundName: undefined,
          subscribedAmount: undefined,
          pageNum: 1,
          pageSize: 10
        },
        // 表单参数
        form: {},
        // 表单校验
        rules: {},
        tempList: []
      }
    },
    created() {
      this.getList()
    },
    methods: {
      /** 查询出资人信息列表 */
      getList() {
        this.loading = true
        findFundInvestor(this.queryParams).then(response => {
          this.fundInvestorList = response.rows
          this.total = response.total
          this.loading = false
        })
      },
      // 表单重置
      reset() {
        this.form = {
          id: undefined,
          type: undefined,
          name: undefined,
          investmentTime: undefined,
          timeSubscriptionArray: undefined,
          incomeDistributionMethod: undefined,
          timeSubscription: undefined,
          subscribedAmount: undefined,
          contractualRateReturn: undefined,
          yieldStructure: undefined,
          currency: undefined,
          partnerType: undefined,
          subscriptionProportion: undefined,
          accumulatedPaidMount: undefined,
          remark: undefined,
          createBy: undefined,
          createTime: undefined,
          updateBy: undefined,
          updateTime: undefined,
          delFlag: undefined
        }
        this.resetForm('form')
      },
      /** 搜索按钮操作 */
      queryHandle() {
        this.queryParams.pageNum = 1
        this.getList()
      },
      /** 重置按钮操作 */
      resetQuery() {
        this.daterange = []
        this.resetForm('queryForm')
        this.queryHandle()
      },
      viewHandle(row) {
        this.investFormOpen = true
        this.title = this.$t('出资人信息')
        this.$nextTick(() => {
          this.$refs.fundInvestorForm.init(row)
        })
      }
    }
  }
</script>

